<?php
class LogRecentBehavior extends CActiveRecordBehavior {

	private $_logRelation;

	public function setLogRelation($relation) {
		$this->_logRelation = $relation;
	}

	public function afterSave($event) {
		$model = $this->getOwner();
		if ($this->_logRelation !== null) {
			$relation = $model->{$this->_logRelation};
			Yii::app()->recent->add($relation);
		} else {
			Yii::app()->recent->add($model);
		}
	}
}
